﻿
@{
    ViewBag.Title = "Editor";
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<script src="//cdn.ckeditor.com/4.6.2/full/ckeditor.js"></script>
<style type="text/css">
    *{
        margin:0;
        padding:0;
    }
  
    .title{
        position:relative;
        width:600px;
        height:40px;
    }
    .title input{
        position:absolute;
        width:90%;
        height:35px;
        margin-left:20px; 
        margin-top:0;    
    }
  .title label{
      margin-top:8px;
  }
    .content{
        display:block;
        width:960px;
        height:500px;
        background-color:red;
        margin-top:40px;
    }
</style>
<h2>Editor</h2>
<div class="container">
    <div class="title"><label for="content_title">标题</label><input type="text" placeholder="请在此处输入标题" id="content_title" name="content_title" /></div>
    <textarea name="Text" id="Text" class="ckeditor content"placeholder="请在此输入正文"></textarea>
    <button class="save">保存</button>
</div>
<script>
    
    $(".save").click(function () {
        var content;
        //alert(CKEDITOR.replace("Text"));
        var editor = CKEDITOR.instances.Text.getData();
        if (editor == "") {
            alert("内容不能为空！");
            return false;
        } else {
            content = CKEDITOR.instances.Text.document.getBody().getText();
            $.ajax({
                url: "Save",
                data: {content:content},
                type: "post",
                success:function(re){
                    alert(re);
            }
            })
            alert(content);
        }
      
    })
  
  
</script>
